{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "eb9cbe78",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f93a2aa",
   "metadata": {},
   "outputs": [],
   "source": [
    "pd.set_option('display.max_rows', 7)\n",
    "pd.set_option('display.max_rows', 7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3479d21a",
   "metadata": {},
   "outputs": [],
   "source": [
    "retail_data=pd.read_excel?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cdda251b",
   "metadata": {},
   "outputs": [],
   "source": [
    "retail_data=pd.read_json?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "28a81c04",
   "metadata": {},
   "outputs": [],
   "source": [
    "retail_data=pd.read_json"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbd44c8b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame([['a','b'],['c','d']], index=['row 1', 'row 2'], columns=['col 1', 'col 2'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "addb2875",
   "metadata": {},
   "outputs": [],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1fdba9d2",
   "metadata": {},
   "outputs": [],
   "source": [
    "index = df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "56e7c9cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "99606109",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a0ae3c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4bbb22d3",
   "metadata": {},
   "outputs": [],
   "source": [
    "type(index)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "24b0d62b",
   "metadata": {},
   "outputs": [],
   "source": [
    "index.values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "124ddb5b",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1']+'f'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7bd2f17f",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d60869a2",
   "metadata": {},
   "outputs": [],
   "source": [
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6381bd64",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1'].isnull()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2c8a16f8",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1'].isnull().sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0444ac90",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1'].isnull().mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5fd6a54a",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1'].fillna(0).head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "ebc7123a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Object `fillna` not found.\n"
     ]
    }
   ],
   "source": [
    "df['col 1'].fillna?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f868b91e",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 1'].fillna"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "0208c661",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 3'] = ['1','2']\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "0a7de856",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "      <th>col 2</th>\n",
       "      <th>col 3</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "      <td>d</td>\n",
       "      <td>2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1 col 2 col 3\n",
       "row 1     a     b     1\n",
       "row 2     c     d     2"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "797f24fe",
   "metadata": {},
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'null' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_25340\\2480242094.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mdf\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;34m'col 4'\u001b[0m\u001b[1;33m]\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;33m[\u001b[0m\u001b[1;34m'1'\u001b[0m\u001b[1;33m,\u001b[0m\u001b[0mnull\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;31mNameError\u001b[0m: name 'null' is not defined"
     ]
    }
   ],
   "source": [
    "df['col 4'] = ['1',null]\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b6d64082",
   "metadata": {},
   "outputs": [],
   "source": [
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "378e4890",
   "metadata": {},
   "outputs": [],
   "source": [
    "df['col 4'].isnull()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "07db84b8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "      <th>col 2</th>\n",
       "      <th>col 3</th>\n",
       "      <th>col 4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "      <td>d</td>\n",
       "      <td>2</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1 col 2 col 3 col 4\n",
       "row 1     a     b     1     1\n",
       "row 2     c     d     2      "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "47dcc145",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "      <th>col 2</th>\n",
       "      <th>col 3</th>\n",
       "      <th>col 4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "      <td>d</td>\n",
       "      <td>2</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1 col 2 col 3 col 4\n",
       "row 1     a     b     1     1\n",
       "row 2     c     d     2      "
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "0415ff25",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "      <th>col 2</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "      <td>b</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "      <td>d</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1 col 2\n",
       "row 1     a     b\n",
       "row 2     c     d"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['col 1', 'col 2']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "8bca47e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.frame.DataFrame"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df[['col 1']])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "4d73ad44",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "row 1    a\n",
       "row 2    c\n",
       "Name: col 1, dtype: object"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['col 1']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "4507f908",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1\n",
       "row 1     a\n",
       "row 2     c"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(like='1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "30d25d3a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "      <th>col 2</th>\n",
       "      <th>col 3</th>\n",
       "      <th>col 4</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "      <td>b</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "      <td>d</td>\n",
       "      <td>2</td>\n",
       "      <td></td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1 col 2 col 3 col 4\n",
       "row 1     a     b     1     1\n",
       "row 2     c     d     2      "
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(like='col')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "7338eb08",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td>c</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 1\n",
       "row 1     a\n",
       "row 2     c"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.filter(items=['col 1', 'cl'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "290f2608",
   "metadata": {},
   "outputs": [],
   "source": [
    "set(['col 4', 'col 3', 'col 2', 'col 1']) == set(df.columns)\n",
    "df_new = df[['col 4', 'col 3', 'col 2', 'col 1']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "e552626a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col 4</th>\n",
       "      <th>col 3</th>\n",
       "      <th>col 2</th>\n",
       "      <th>col 1</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>row 1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>b</td>\n",
       "      <td>a</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>row 2</th>\n",
       "      <td></td>\n",
       "      <td>2</td>\n",
       "      <td>d</td>\n",
       "      <td>c</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      col 4 col 3 col 2 col 1\n",
       "row 1     1     1     b     a\n",
       "row 2           2     d     c"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_new"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "5eea2d6f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.43343653250773995"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "140/323"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "6f9fa9c2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.29721362229102166"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "96/323"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a8f64fe4",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
